<template>
	<view class="home">
		
		<view class="user_top">
			<text>会员中心--修改地址</text>
		</view>
		
		<text>{{products.uid}}</text>
	   
		<view class="input">
	
		   <view class="input1"><input name="username" v-model="username" placeholder="请输入收货人姓名"  /></view>

		</view>
		
		<view class="input">
		   <view class="input1"><input type="text" name="phone" v-model="phone" placeholder="请输入收货人电话" /></view>
		</view>
		
		<view class="input">
		   <view class="input1"><input type="text"  name="useraddress" v-model="useraddress"  placeholder="请输入详细地址"/></view>
		</view>
		
		<view class="input2">
		  <button type="primary" @click="btn_add">修改</button>
		</view>
		
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				username:"",
				phone:"",
				useraddress:"",
				products:{}
			}
		},
		onLoad(options) {
			this.id=options.id
			this.xiangqing()
		},
		methods: {
			
			back(){
				uni.navigateBack({
					delta: 1,
				});
			},
			async xiangqing(){
				
				const res = await this.$myRuquest({
					url:'/index/dsnv.activities/address_one_edit',
					method:'post',
					data:{
						"id":this.id,
					},
				})
				
				if(res.data.code ==200){
					this.username = res.data.date.username
					this.phone = res.data.date.phone
					this.useraddress = res.data.date.useraddress
				}else{
					uni.showToast({
						title: res.data.info,
						duration: 3000,
						icon: 'none'
					})			
				}
				
			},
			async btn_add(){
				
				const res = await this.$myRuquest({
					url:'/index/dsnv.activities/address_edit',
					method:'post',
					data:{
						"id":this.id,
						"username":this.username,
						"phone":this.phone,
						"useraddress":this.useraddress,
					},
				})
				
				if(res.data.code ==200){
					
					uni.navigateTo({
						url: '/pages/my/address/address'
					});
					
					setTimeout(() => {
					
								uni.showToast({
									title: res.data.info,
									icon: 'none'
								});
							}, 400)
				
				}else{
					uni.showToast({
						title: res.data.info,
						duration: 3000,
						icon: 'none'
					})			
				}
			
				
			}
			
			
		}
	}
</script>

<style>
	.home{		
		
	}
	.user_top{
		text-align: center;
	}
	
	.input{
		height: 40px;
		border-radius: 20px;
		border: 1px solid #D0D0D0;
		margin: 20px 20px;
	}
	.input1{
		padding-top:8px;
		padding-left:20px;
		height: 25px;
	}
	.input2{
		height: 40px;
		margin: 20px 20px;
	}
	

</style>
